package com.wgchao.patientcenter.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @ClassName: ResultCommon
 * @author: wgchao
 * @createTime: 2019/10/14 8:59 AM
 * @Description: 公共结果
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultCommon<T>  {
    private String code;
    private String msg;
    private T data;

    public static ResultCommon success() {
        ResultCommon rc = new ResultCommon();
        rc.code = "200";
        rc.msg = "success";
        return rc;
    }

    public static ResultCommon fail(String msg) {
        ResultCommon rc = new ResultCommon();
        rc.code = "999";
        rc.msg = msg;
        return rc;
    }

    public static ResultCommon fail(String code, String msg) {
        ResultCommon rc = new ResultCommon();
        rc.code = code;
        rc.msg = msg;
        return rc;
    }

    public ResultCommon setMsg(String msg){
        this.msg = msg;
        return this;
    }

    public ResultCommon setData(T data){
        this.data = data;
        return this;
    }
}
